package com.lanou.springboottest.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/")
public class HelloController {

	@RequestMapping("hello")
	//@ResponseBody
	public ModelAndView hello(String username,ModelAndView modelAndView){
		modelAndView.setViewName("hello");
		List<User> list = new ArrayList<>();
		for (int i = 0; i < 5; i++) {
			User user = new User();
			user.setUsername("zhangsan" + i);
			user.setPassword("123");
			list.add(user);
		}
		int a = 10;
		modelAndView.addObject("username",username);
		modelAndView.addObject("result",list);
		modelAndView.addObject("flag",a);
		return modelAndView;
	}
}
